package com.abel.servicegoods.controller;

import com.abel.servicegoods.feign.TestFeign;
import com.abel.servicegoods.service.UserService;
import com.abel.servicemodel.user.Login;
import com.abel.servicemodel.user.UserInnodb;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
public class Test {
    @Autowired
     private TestFeign testFeign;
    @Autowired
    private UserService userService;
    @Value("${base.redis.port}")
    private  String port;
    @GetMapping("/hello")
    public String testHello(HttpServletRequest request){
        HttpSession session=request.getSession();
    Object obj = session.getAttribute("user");
        System.out.println(port);
    if (obj==null){
        System.out.println("未登录");
        return  "请登录";
    }
        System.out.println("商品服务");
        return  testFeign.hello();
    }
    @GetMapping("/user")
    public List<UserInnodb> getUser(){
        return  userService.find();
    }
    @GetMapping("/te")
    public void  sd(){
        System.out.println(port);
    }
}
